import TableNameEnum from '@/enumeration/TableNameEnum';
import Dexie from 'dexie';

export default class DexieInstance extends Dexie {

    constructor() {
        super('read');
        this.version(2).stores({
            // 资讯项
            resourceItem: '++id, sourceId',
            // 订阅项
            subscribeItem: '++id, sourceId',
            // 书籍缓存-项
            bookCacheItem: '++id, sourceId, [sourceId+bookSourceId], [sourceId+bookSourceId+key]',
            // 书籍缓存-内容
            bookCacheBody: '++id, &sourceId',
            // 阅读记录
            readRecord: '++id'
        }).upgrade(trans => {
            console.log(trans);
            // 更新
        })
    }

    getTable<T>(name: TableNameEnum): Dexie.Table<T> {
        return this.table(name);
    }

}